package app.server.project.main.service.db.dao.user;

import app.server.project.main.service.db.entity.user.SolanaSlotEntity;
import app.server.project.main.service.db.mapper.user.SolanaSlotMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class SolanaSlotDao extends ServiceImpl<SolanaSlotMapper, SolanaSlotEntity> {

    @Cacheable(key = "#id", cacheNames = "app.server.project.main.service.db.dao.SolanaSlotDao")
    public List<SolanaSlotEntity> getAll(int id) {
        var data = this.list(Wrappers.lambdaQuery(SolanaSlotEntity.class).orderByDesc(SolanaSlotEntity::getSlot));
        data.forEach(e -> e.setSynDb(true));
        return new ArrayList<>(data);
    }


}
